<template>
  <div class="footer-box" :style="{ background: props.background }">
    <!-- <div class="footer-logo">
      <img
        class="t-image--fit-contain t-image--position-center"
        :src="$filters.getLinkUrl(store.styleInfo.logo, '?imageView2/2/w/380/h/100/format/webp')"
        alt=""
        v-if="store.styleInfo.logo"
      />
    </div> -->
    <div class="footer-tab">
      <div v-for="(item, index) in tabList" :key="index" class="underLineBox">
        <span
          class="tab-item"
          @click="setCruuent(index, item.isShow)"
          :style="{
            fontSize: store.styleInfo.contentSize,
            color: '#fff',
          }"
          :class="{ 'item-right-border': index == 0, 'tab-item-null': !item.isShow }"
        >
          <div class="solid" v-if="index !== 0"></div>
          {{ item.name }}</span
        >
        <div
          :class="flag === item.id ? 'underLine1' : 'underLine'"
          :style="{
            maxWidth: index === 0 ? '35px' : '100%',
          }"
        ></div>
      </div>
    </div>
    <!-- <span class="footer-title1" :style="{ fontSize: store.styleInfo.contentSize, color: store.styleInfo.fontColor }">
      鄂ICP备12065373号·Copyright©2023 武汉犹新记忆科技有限公司·All Rights Reserved
    </span>
    <span
      class="footer-title2 footer-title1"
      :style="{ fontSize: store.styleInfo.contentSize, color: store.styleInfo.fontColor }"
    >
      版权所有：武汉犹新记忆科技有限公司
    </span> -->
  </div>
  <div class="footer-logo-box" :style="{ background: props.background }">
    <div class="footer-logo-content"></div>
    <!-- <div class="footer-logo" @click="goHome">
      <img src="https://static.jiyi.show/template/template1/footerLogo.svg" alt="" />
      <div>· 永不落幕的展览与展示平台</div>
    </div> -->
    <a :href="porturls" target="_blank" rel="noopener noreferrer" class="footer-logo">
      <img src="https://static.jiyi.show/template/template1/footerLogo.svg" alt="" />
      <div>· 永不落幕的展览与展示平台</div>
    </a>
  </div>
</template>

<script setup lang="ts">
// @ts-nocheck
import { computed, ref, watch } from 'vue';
import { urls } from '@/utils/request/upload';
import { useProjectStore } from '@/store';
import { settings } from '@/api/project/project';
import { storeToRefs } from 'pinia';
import { useRoute, useRouter } from 'vue-router';
import { pathList, pathListLoop } from '../route';
const route = useRoute();
const router = useRouter();
const tabList = ref([
  { name: '首页', isShow: true, id: 0 },
  { name: '展品图库', isShow: true, id: 1 },
  { name: '文创商品', isShow: true, id: 4 },
  { name: '版权声明', isShow: true, id: 5 },
  { name: '学术研究', isShow: true, id: 3 },
  { name: '留言板', isShow: true, id: 2 },
]);
const porturls = computed(() => {
  if (import.meta.env.MODE === 'development') {
    return 'http://t-www.jiyi.show';
  } else {
    return 'https://www.jiyi.show';
  }
});
const flag = ref(-1);
const store = useProjectStore();
const { tabvalue } = storeToRefs(store);
const props = defineProps({
  modelValue: {
    type: Number,
  },
  background: {
    type: String,
    default: '#CFBDA8',
  },
  color: {
    type: String,
    default: '#ffffff',
  },
});
const emit = defineEmits(['update:modelValue', 'setCruuent']);
const setCruuent = (e: Number, show: boolean) => {
  if (!show) {
    return;
  }
  emit('update:modelValue', e);
  emit('setCruuent', e);
  window.scrollTo({ top: 0 });
  var dom = document.getElementById('template1-scorll-box');
  dom.scrollTo({ top: 0 });
};
const goHome = () => {
  // console.log('goHome');

  router.push({
    name: route.meta.loopType ? pathListLoop[0] : pathList[0],
    // query: { projectId: localStorage.getItem('projectId') },
  });
};
const initSetting = async () => {
  try {
    let res = await settings(localStorage.getItem('projectId'), 3);
    res.data.forEach((element) => {
      if (!element.config) {
        switch (element.type) {
          case 2:
            tabList.value[5].isShow = false;
            break;
          case 3:
            tabList.value[4].isShow = false;
            break;
          case 4:
            tabList.value[2].isShow = false;
            break;
          case 5:
            tabList.value[3].isShow = false;
            break;
        }
      }
    });
    // //console.log(tabList.value);
  } catch {}
};
initSetting();
watch(
  () => tabvalue,
  () => {
    initSetting();
  },
  { deep: true },
);
watch(
  () => route.name,
  () => {
    //console.log(route.name === 'templateExhibitsLoop', '9999999999999999999999');

    switch (route.name) {
      case 'templateHome':
      case 'templateHomeLoop':
        flag.value = 0;
        break;
      case 'templateExhibits':
      case 'templateExhibitsLoop':
        flag.value = 1;
        break;
      case 'templateCommodity':
      case 'templateCommodityLoop':
        flag.value = 4;
        break;
      case 'templateCopyright':
      case 'templateCopyrightLoop':
        flag.value = 5;
        break;
      case 'templateResearch':
      case 'templateResearchLoop':
        flag.value = 3;
        break;
      case 'templateBoard':
      case 'templateBoardLoop':
        flag.value = 2;
        break;
      default:
        flag.value = -1;
        break;
    }

    //console.log(flag.value, 'flag');
  },
  { deep: true, immediate: true },
);
</script>

<style lang="less" scoped>
.footer-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
}
.footer-logo {
  width: 380px;
  height: 100px;
  // background: #d8d8d8;
  margin-bottom: 40px;
  img {
    width: 380px;
    height: 100px;
  }
}
.footer-tab {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  width: 100%;
  // margin-bottom: 32px;
  .tab-item {
    display: flex;
    align-items: center;
    height: 24px;
    position: relative;
    cursor: pointer;
    font-size: 16px;
    font-weight: 400;
    line-height: 22px;
    padding: 0 40px;
    // border-left: 1px solid #ffffff;
    .solid {
      position: absolute;
      top: 6px;
      left: 0;
      width: 1px;
      height: 12px;
      background: #fff;
    }
  }
  .tab-item-null {
    // opacity: 0.3;
    display: none;
  }

  .underLine {
    width: 0px;
    height: 1px;
    background: #fff;
    margin: auto;
    margin-top: 3px;
    transition: all 0.5s;
  }
  .underLineBox:hover .underLine {
    width: 70px;
  }
  .underLine1 {
    width: 70px;
    height: 1px;
    background: #fff;
    margin: auto;
    margin-top: 3px;
    transition: all 0.5s;
  }
  .item-right-border {
    border: none;
  }
}
.footer-title1 {
  font-size: 16px;
  // font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #ffffff;
  line-height: 22px;
}
.footer-title2 {
  margin-top: 8px;
}
.footer-logo-box {
  width: 100%;
  height: 50px;
  overflow: hidden;
  // display: flex;
  // flex-direction: column;
  // align-items: center;
  // justify-content: center;
}
.footer-logo-content {
  width: 100%;
  height: 1px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.26) 50.56%,
    rgba(255, 255, 255, 0) 100.42%
  );
  margin: auto;
}
.footer-logo {
  width: 300px;
  margin: auto;
  height: 26px;
  display: flex;
  justify-content: center;
  align-items: center;
  color: rgba(255, 255, 255, 1);
  margin-top: 14px;
  margin-bottom: 10px;
  cursor: pointer;
  img {
    width: 76px;
    height: 26px;
    margin-right: 8px;
  }
}
a {
  font-family: none !important;
}
</style>
